import { TEXT, SELECT } from '@/conf/uiTypes'
export const tableConf = Object.freeze({
  // Object.isFrozen(); 是否被冻结，被冻结就跳过响应式
  multipleSelection: true,
  index: true,
})
export const columns = Object.freeze(
  [
    {
      prop: 'birthday',
      label: '出生日期',
      width: 120,
    },
    {
      prop: 'name',
      label: '姓名',
      width: 120,
    },
    {
      label: '性别',
      prop: 'sex',
    },
    {
      prop: 'education',
      label: '教育程度',
    },
    {
      prop: 'address1',
      label: '居住地址',
    },
    {
      prop: 'mobile_phone',
      label: '手机号',
    },
    {
      label: '申请状态',
      prop: 'status',
      width:100
    },
    {
      label: '操作',
      prop: 'operation',
      width: 300,
    },
    {
      label: '配送信息',
      width: 800,
      children: [
        {
          label: '地址',
          children: [
            { label: '省份', prop: 'name' },
            { label: '市区' },
            { label: '街道', prop: 'address' },
          ],
        },
      ],
    },
    {
      width: 400,
      label: '显示html',
      prop: 'xxx',
      formatter(prop) {
        return `<div>
            <h2>${prop.row.name}这是自定义html</h2>
            <button>按钮</button>
        </div>`
      },
    },
  ].map((ele) => ({ ...ele, align: 'center' }))
)

//性别
export const sexOptions = [
  { value: 'man', label: '男' },
  { value: 'woman', label: '女' },
]

export const genEditForm = function (row) {
  return {
    items: [
      [
        {
          label: '姓名',
          value: row.name,
          key: 'name',
          colspan: 22,
          type: TEXT,
        },
      ],
      [
        {
          label: '性别',
          value: row.sex,
          key: 'sex',
          colspan: 22,
          type: SELECT,
          options: sexOptions,
        },
      ],
    ],
    rules: {
      name: [{ required: true, message: '必须输入用户名', trigger: 'blur' }],
      sex: [{ required: true, message: '必须输入性别', trigger: 'blur' }],
    },
  }
}
